Skip to content

Fix error when a shared event loop is unset #1180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tjkuson
Copy link
Contributor

@tjkuson tjkuson commented Aug 9, 2025

Automatically reinstates the event loop on the main thread when needed.

We reinstate in wrap_in_sync() as an event loop is required here; without reinstating the event loop here, the next async test will fail to run.

The coverage report suggests the patch is uncovered, but I think this is due to limitations of measuring coverage across processes.

Fixes #1177

Note: this is a work-in-progress proposal based on my understanding of the issue. If the maintainers prefer a different approach or consider the issue invalid, I’m happy to adjust or close this PR.

@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.68%. Comparing base (2c75c45) to head (bb8628a).

Files with missing lines Patch % Lines
pytest_asyncio/plugin.py 40.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1180      +/-   ##
==========================================
- Coverage   88.88%   87.68%   -1.21%     
==========================================
  Files           2        2              
  Lines         405      414       +9     
  Branches       44       45       +1     
==========================================
+ Hits          360      363       +3     
- Misses         35       41       +6     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tjkuson tjkuson force-pushed the mainthread-fix branch 2 times, most recently from 7fa2f06 to 5ff08a0 Compare August 9, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RuntimeError when the event loop is unset between tests
2 participants